using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cameraController : MonoBehaviour
{
    private CinemachineVirtualCamera virtualCamera1;
    private CinemachineTargetGroup virtualTargetGroup;
    //private BoxCollider2D virtualCamera1Trigger;
    //private BoxCollider2D virtualCamera2Trigger;
    //private BoxCollider2D virtualCamera3Trigger;
    private BoxCollider2D virtualTargetGroupTrigger;
    // Start is called before the first frame update
    void Start()
    {
        virtualCamera1 = GetComponentInChildren<CinemachineVirtualCamera>();
        virtualCamera1.enabled = true;
        //virtualCamera2 = GetComponentInChildren<CinemachineVirtualCamera>();
        //virtualCamera3 = GetComponentInChildren<CinemachineVirtualCamera>();
        virtualTargetGroup = GetComponentInChildren<CinemachineTargetGroup>();
        virtualTargetGroup.enabled = false;
        //virtualCamera1Trigger = GetComponentInChildren<BoxCollider2D>();
        //virtualCamera2Trigger = GetComponentInChildren<BoxCollider2D>();
        //virtualCamera3Trigger = GetComponentInChildren<BoxCollider2D>();
        virtualTargetGroupTrigger = GetComponentInChildren<BoxCollider2D>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision is CapsuleCollider2D && collision.CompareTag("Player"))
        {
            virtualCamera1.enabled = false;
            virtualTargetGroup.enabled = true;
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if(collision is CapsuleCollider2D && collision.CompareTag("Player"))
        {
            virtualCamera1.enabled = true;
            virtualTargetGroup.enabled = false;
        }
    }
}
